<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
     window.onload=()=>{
         let oBtn=document.getElementById("btn1");
         oBtn.onclick=()=>{
             //1.创建一个对象
             let xhl=new XMLHttpRequest();
             //2.连接服务器
             xhl.open("GET","1.text",true);
             //3.发送一个信息
             xhl.send();
             //4.接收
             xhl.onreadystatechange=()=>{
                //  alert(xhl.readyState);
                 if(xhl.readyState==4){
                     alert("完成!")
                 }
             };
         }
     }
    </script>
</head>
<body>
    <input type="button"    value="按钮" id="btn1">
</body>
</html>